

	

layui.use(['form','layer'],function(){
    var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;
		

	//初始化
	const selectType=new Vue({
			el: '#selectType',
			data:{
				  all_data:[],
				  layform:null,
				
			},
			methods:{
				getAllType:function(){
					this.$http.post(global_url+'/admin/novel/categorys/all").then(
						response=>{
							this.all_data=response.body.datas.category;
						
							setTimeout(function(){
								form.render('select');
							},100);
							
	
						},
						response=>{
							
						}
					)
				},
				addType:function(data){
					
					this.$http.post(global_url+'/admin/category/add/",data).then(
						response=>{
							if(response.body.msg=="success"){
								//刷新父页面
								parent.location.reload();
								layer.msg("success!!!")
							}else{	
								layer.msg(response.body.code)
							}
						},
						response=>{
							
						}
					)
				}
			}
		})
	selectType.getAllType()
	
    form.on("submit(addType)",function(data){
		
		category={
			"categoryName":$(".typeName").val(),
			"categorySonId":data.field.typeSelect
		}
		selectType.addType(category)
		return false;
    })

 
})